from django.db import models


class Publisher(models.Model):
    name = models.CharField(verbose_name="出版社", max_length=72)
    isbn = models.CharField(verbose_name="ISBN", max_length=72)
    address = models.CharField(verbose_name="地址", max_length=72)
    code = models.IntegerField(verbose_name="编码")
    telphone = models.CharField(verbose_name="电话", max_length=72)
    fax = models.CharField(verbose_name="传真", max_length=72)


class Author(models.Model):
    """作者"""
    name = models.CharField(verbose_name="作者", max_length=24)
    gender = models.CharField(verbose_name="性别", max_length=6)
    birthday = models.DateField(verbose_name="生日")
    phone = models.CharField(verbose_name="手机", max_length=11)
    wechat = models.CharField(verbose_name="微信", max_length=24)
    qq = models.CharField(verbose_name="QQ", max_length=11)
    email = models.CharField(verbose_name="邮箱", max_length=72)


class Book(models.Model):
    """图书"""
    name = models.CharField(verbose_name="书名", max_length=72)
    price = models.DecimalField(verbose_name="价格", max_digits=6, decimal_places=2)
    intro = models.CharField(verbose_name="简介", max_length=256)
    pub_date = models.DateField(verbose_name="出版时间")
    author = models.ForeignKey(verbose_name="作者", to='Author', on_delete=models.CASCADE)
    publisher = models.ForeignKey(verbose_name="出版社", to='Publisher', on_delete=models.CASCADE)
